<template>
  <div class="inline-flex align-center custom-tabs">
    <div
      class="tab-item" v-for="tab in tabs" :key="tab.value"
      :style="{
        color: value === tab.value ? 'white' : themeColor,
        backgroundColor: value === tab.value ? themeColor : 'white',
        borderColor: value === tab.value ? themeColor : '#dddddd'
      }"
      @click="clickItem(tab)"
    >
      {{ tab.name }}
    </div>
  </div>
</template>

<script>
export default {
  name: 'custom-tabs',
  model: {
    prop: 'value',
    event: 'input'
  },
  props: {
    value: [String, Number],
    tabs: {
      type: Array,
      default () {
        return []
      }
    }
  },
  computed: {
    themeColor () {
      return this.$store.state.user.theme
    }
  },
  methods: {
    clickItem (tab) {
      this.$emit('input', tab.value)
      this.$emit('change', tab)
    }
  }
}
</script>

<style lang="scss" scoped>
.custom-tabs {
}
$radius: 20px;
.tab-item {
  padding: 10px 15px;
  border: 1px solid;
  margin-left: -1px;
  cursor: default;
  &:first-child {
    margin-left: 0;
    border-top-left-radius: $radius;
    border-bottom-left-radius: $radius;
  }
  &:last-child {
    border-top-right-radius: $radius;
    border-bottom-right-radius: $radius;
  }
}
</style>
